//
//  YAYIPhotoItemCell.m
//  图片多选
//
//  Created by hxp on 16/6/27.
//  Copyright © 2016年 hxp. All rights reserved.
//

#import "YAYIPhotoItemCell.h"

@implementation YAYIPhotoItemCell
-(instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createViews];
    }
    return self;
}
-(void)createViews{
    self.photo = [[UIImageView alloc] initWithFrame:CGRectZero];
    [self.contentView addSubview:self.photo];
    
    self.selectImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
    self.selectImageView.backgroundColor = YAYIColorAlpha(255, 255, 255, 0.4);
//    self.selectImageView.image = [UIImage imageNamed:@"Overlay"];
    self.selectImageView.hidden = YES;
    [self.contentView addSubview:self.selectImageView];
    
    self.checkedImageView = [[UIImageView alloc] initWithFrame:CGRectZero];
    self.checkedImageView.image = [UIImage imageNamed:@"PickerChecked"];
    [self.selectImageView addSubview:self.checkedImageView];
}
-(void)layoutSubviews
{
    [super layoutSubviews];
    self.photo.frame = CGRectMake(0, 0, CGRectGetWidth(self.contentView.frame), CGRectGetHeight(self.contentView.frame));
    
    self.selectImageView.frame = self.contentView.bounds;
    CGFloat checkedWH = 30;
    CGFloat checdedX = self.contentView.width - 30 - 5;
    CGFloat checdedY = self.contentView.height - 30 - 5;
    self.checkedImageView.frame = CGRectMake(checdedX, checdedY, checkedWH, checkedWH);
    //self.selectImageView.frame = CGRectMake(0, 0, 94, 94);
}


-(void)changeSelectedWithALAsset:(ELNALAsset *)asset{
    if (asset.isSelected) {
//        self.selectImageView.frame = CGRectMake(0, 0, CGRectGetWidth(self.contentView.frame), CGRectGetHeight(self.contentView.frame));
        self.selectImageView.hidden = NO;
    }else{
//        self.selectImageView.frame = CGRectMake(0, 0, 0, 0);
        self.selectImageView.hidden = YES;
    }
}
@end
